<!--
 * @Author: wangxia1
 * @Date: 2023-09-11 15:37:34
 * @Description: 流程跟踪处理人详细信息弹窗
-->
<template>
  <div>
    <el-dialog
      v-bind="dialogAttrs"
      width="500px"
      title="详细信息"
      :visible.sync="dialogVisible"
      customClass="user-info-dialog"
      v-el-drag-dialog="true"
      @close="hide"
    >
      <el-descriptions :column="1" border>
        <el-descriptions-item label="姓名">{{ infoData.userName }}</el-descriptions-item>
        <el-descriptions-item label="部门">{{ infoData.dept }}</el-descriptions-item>
        <el-descriptions-item label="用户名">{{ infoData.userNamePinYin }}</el-descriptions-item>
        <el-descriptions-item label="域编码">{{ infoData.domainCode }}</el-descriptions-item>
      </el-descriptions>
      <div slot="footer" class="dialog-footer">
        <el-button @click="hide">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import settings from '@/settings/settings';
import { UserBaseService } from 'jdf-jssdk';
import { bizServiceURL } from '@/api/utils/constants';

export default {
  name: 'processUserInfo',
  props: {
    visible: Boolean,
    row: Object,
    column: Object,
  },
  watch: {
    visible: {
      handler(val) {
        val && this.show();
      },
      immediate: true
    }
  },
  data() {
    return {
      dialogAttrs: settings.dialogAttrs,
      dialogVisible: false,
      infoData: {}
    };
  },
  methods: {
    /**
     * 隐藏窗口
     */
    hide() {
      this.dialogVisible = false;
      this.$emit('update:visible', false);
    },
    /**
     * 打开窗口
     */
    async show(row, column) {
      await this.getUserInfo(row, column);
      this.dialogVisible = true;
    },
    async getUserInfo() {
      const { userName, deptId, userCode } = this.row.operateUser;
      const deptFullName = await new UserBaseService(bizServiceURL).getFullPath(deptId);
      const { userNamePinYin, domainCode } = await new UserBaseService(bizServiceURL).getByUserCode(userCode);
      this.infoData = {
        userName,
        dept: deptFullName,
        userNamePinYin,
        domainCode
      };
    }
  }
};
</script>
<style lang='scss'>
@import '@/assets/style/variables.scss';

.user-info-dialog {
  .el-dialog__body {
    padding: 10px;
  }
}
</style>
